<template>
  <div class="app-container">
    <el-row>
      <el-col :span="14" style="background:white">
        <!-- 补贴单信息 -->
        <h5 class="titleInfo">补贴单信息</h5>
        <el-form ref="list" :inline="true" label-position="top" :model="list" label-width="150px">
          <el-row>
            <el-col :span="8">
              <el-form-item label="补贴单号">
                <span class="spanToInput" :title="list.applySn">
                  {{
                  list.applySn | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="预约医院">
                <span class="spanToInput" :title="list.hospitalName">
                  {{
                  list.hospitalName | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="预约项目">
                <span class="spanToInput" :title="list.projectName">
                  {{
                  list.projectName | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="8" v-if="list.formType">
              <el-form-item label="单数" v-if="list.formType.indexOf('传统') == -1">
                <span class="spanToInput">{{ list.count | filterNull }}</span>
              </el-form-item>
              <el-form-item label="消费金额" v-else>
                <span class="spanToInput">{{ list.money }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="扣除杂费金额">
                <span class="spanToInput">
                  {{
                  (list.deductOtherPrice-0+(list.useCoin-0?list.useCoin-0:'')) | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="补贴金额">
                <span class="spanToInput">
                  {{list.deductOtherPrice | filterNull}}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="金币">
                <span class="spanToInput">
                  {{list.useCoin | filterNull}}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="创建时间">
                <span class="spanToInput" :title="list.createdAt">
                  {{
                  list.createdAt | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="流水时间">
                <span class="spanToInput" :title="list.createdAt2">
                  {{
                  list.createdAt2 | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="报单类型">
                <span class="spanToInput">
                  {{
                  list.formType | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="分成模式">
                <span class="spanToInput">
                  {{
                  list.separateType | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <!-- 业绩奖励 -->
        <div class="divBar" />
        <h5 class="titleInfo">业绩奖励</h5>

        <el-form ref="list" :inline="true" :model="list" label-width="150px">
          <el-row v-for="(item, index) in list.rewardUserArchivementList" :key="index">
            <el-col :span="12">
              <el-form-item :label="item.name">
                <span class="spanToInput">{{ item.personnel }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="人员级别">
                <span class="spanToInput">{{ item.personnelDesc }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励比例(%)">
                <span class="spanToInput">{{ item.personnelUserBili }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励金额">
                <span class="spanToInput">{{ item.personnelPrice }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12" v-if="list.useCoin-0">
              <el-form-item label="金币奖励比例(%)">
                <span class="spanToInput">{{ item.goldPersonnelUserBili }}</span>
                <!-- <el-input disabled>{{ item.goldPersonnelUserBili }}</el-input> -->
                <span >{{ item.goldFrozenMsg  }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12" v-if="list.useCoin-0">
              <el-form-item label="金币奖励金额">
                <span class="spanToInput">{{ item.goldPersonnelPrice }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <!-- <el-row>
            <el-col :span="12">
              <el-form-item label="二级人员">
                <span class="spanToInput">{{ list.levelTwoPersonnel | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="人员级别">
                <span class="spanToInput">{{ list.levelTwoPersonnelDesc | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励比例(%)">
                <span
                  class="spanToInput"
                >{{ list.levelTwoPersonnelRefRefereeUserBili | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励金额">
                <span class="spanToInput">{{ list.levelTwoPersonnelRefRefereePrice | filterNull }}</span>
              </el-form-item>
            </el-col>
          </el-row>-->
        </el-form>
        <!-- 团队奖励 -->
        <div class="divBar" />
        <h5 class="titleInfo">团队奖励</h5>
        <el-form
          v-if="list.teamRewardUsers"
          ref="list"
          :inline="true"
          :model="list"
          label-width="150px"
        >
          <el-row v-for="(i, index) in list.teamRewardUsers" :key="index">
            <el-col :span="12">
              <el-form-item label="奖励人员">
                <span class="spanToInput">{{ i.personnel | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="人员级别">
                <span class="spanToInput">{{ i.desc | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励比例(%)">
                <span class="spanToInput">{{ i.bili | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励金额">
                <span class="spanToInput">{{ i.price | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="金币奖励比例(%)">
                <span class="spanToInput">{{ i.goldBili }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="金币奖励金额">
                <span class="spanToInput">{{ i.goldPrice }}</span>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <!-- 区域奖励 -->
        <div class="divBar" />
        <h5 class="titleInfo">区域奖励</h5>
        <el-form
          v-if="list.bigAreaRewardUsers"
          ref="list"
          :inline="true"
          :model="list"
          label-width="150px"
        >
          <el-row v-for="(i, index) in list.bigAreaRewardUsers" :key="index">
            <el-col :span="12">
              <el-form-item label="奖励人员">
                <span class="spanToInput">{{ i.personnel | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="人员级别">
                <span class="spanToInput">{{ i.desc | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励比例(%)">
                <span class="spanToInput">{{ i.bili | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励金额">
                <span class="spanToInput">{{ i.price | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="金币奖励比例(%)">
                <span class="spanToInput">{{ i.goldBili | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="金币奖励金额">
                <span class="spanToInput">{{ i.goldPrice | filterNull}}</span>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <!-- 二单奖励 -->
        <div class="divBar" />
        <h5 class="titleInfo">二单奖励</h5>
        <el-form
          v-if="list.rewardTwoRewardUsers"
          ref="list"
          :inline="true"
          :model="list"
          label-width="150px"
        >
          <el-row v-for="(i, index) in list.rewardTwoRewardUsers" :key="index">
            <el-col :span="12">
              <el-form-item label="奖励人员">
                <span class="spanToInput">{{ i.personnel | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="人员级别">
                <span class="spanToInput">{{ i.desc | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励比例(%)">
                <span class="spanToInput">{{ i.bili | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励金额">
                <span class="spanToInput">{{ i.price | filterNull }}</span>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <!-- 团队二单奖励 -->
        <div class="divBar" />
        <h5 class="titleInfo">团队二单奖励</h5>
        <el-form
          v-if="list.teamTwoRewardUsers "
          ref="list"
          :inline="true"
          :model="list"
          label-width="150px"
        >
          <el-row v-for="(i, index) in list.teamTwoRewardUsers " :key="index">
            <el-col :span="12">
              <el-form-item label="奖励人员">
                <span class="spanToInput">{{ i.personnel | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="人员级别">
                <span class="spanToInput">{{ i.desc | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励比例(%)">
                <span class="spanToInput">{{ i.bili | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励金额">
                <span class="spanToInput">{{ i.price | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="金币奖励比例(%)">
                <span class="spanToInput">{{ i.goldBili | filterNull }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="金币奖励金额">
                <span class="spanToInput">{{ i.goldPrice | filterNull }}</span>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <!-- 分公司奖励 -->
        <div class="divBar" />
        <h5 class="titleInfo">分公司奖励</h5>
        <el-form
          v-if="list.areaRewardUser"
          ref="list"
          :inline="true"
          :model="list"
          label-width="150px"
        >
          <el-row>
            <el-col :span="12">
              <el-form-item label="公司奖励">
                <span class="spanToInput">
                  {{
                  list.areaRewardUser.name | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="公司电话">
                <span class="spanToInput">
                  {{
                  list.areaRewardUser.userName | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励比例(%)">
                <span class="spanToInput">
                  {{
                  list.areaRewardUser.bili | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励金额">
                <span class="spanToInput">
                  {{
                  list.areaRewardUser.price | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="金币奖励比例(%)">
                <span class="spanToInput">
                  {{
                  list.areaRewardUser.goldBili | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="金币奖励金额">
                <span class="spanToInput">
                  {{
                  list.areaRewardUser.goldPrice | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <!-- 试用业绩提成奖励 -->
        <div class="divBar" />
        <h5 class="titleInfo">试用业绩奖励</h5>
        <el-form ref="list" :inline="true" :model="list" label-width="150px">
          <el-row v-if="list.attemptRefereeUser">
            <el-col :span="12">
              <el-form-item label="奖励人员">
                <span class="spanToInput">
                  {{
                  list.attemptRefereeUser.personnel | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="人员级别">
                <span class="spanToInput">
                  {{
                  list.attemptRefereeUser.desc | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励比例(%)">
                <span class="spanToInput">
                  {{
                  list.attemptRefereeUser.bili | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励金额">
                <span class="spanToInput">
                  {{
                  list.attemptRefereeUser.price | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
          </el-row>
          <!-- 团队试用业绩提成 -->
          <div class="divBar" />
          <h5 class="titleInfo">试用团队奖励</h5>
          <el-row v-if="list.attemptTeamUser">
            <el-col :span="12">
              <el-form-item label="奖励人员">
                <span class="spanToInput">
                  {{
                  list.attemptTeamUser.personnel | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="人员级别">
                <span class="spanToInput">
                  {{
                  list.attemptTeamUser.desc | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励比例(%)">
                <span class="spanToInput">
                  {{
                  list.attemptTeamUser.bili | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励金额">
                <span class="spanToInput">
                  {{
                  list.attemptTeamUser.price | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
          </el-row>
          <!-- 大区域使用业绩提成 -->
          <div class="divBar" />
          <h5 class="titleInfo">试用大区域奖励</h5>
          <el-row v-if="list.attemptBigUser">
            <el-col :span="12">
              <el-form-item label="奖励人员">
                <span class="spanToInput">
                  {{
                  list.attemptBigUser.personnel | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="人员级别">
                <span class="spanToInput">
                  {{
                  list.attemptBigUser.desc | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励比例(%)">
                <span class="spanToInput">
                  {{
                  list.attemptBigUser.bili | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="奖励金额">
                <span class="spanToInput">
                  {{
                  list.attemptBigUser.price | filterNull
                  }}
                </span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item>
                <el-button
                  :disabled="list.separate"
                  style="margin-top:30px;margin-left:130px"
                  type="primary"
                  @click="auditSubmit()"
                >立即提交</el-button>
              </el-form-item>

              <el-form-item>
                <el-button
                  style="margin-top:30px;margin-left:10px"
                  type="primary"
                  @click="refresh()"
                >刷新</el-button>
              </el-form-item>
            </el-col>
            <p v-if="list.separate">该医院未维护传统报单分成比例，不可审核</p>
            <!-- 审核弹窗 -->
            <el-dialog title="审批" :visible.sync="dialogAudit" width="468px">
              <div style="margin-bottom:20px;">
                <el-radio v-model="radio" label="1">审核通过</el-radio>
                <el-radio v-model="radio" label="2">审核驳回</el-radio>
              </div>
              <el-form :inline="true" label-width="80px" v-if="radio==11" label-position="right">
                <el-input type="textarea" v-model="remark" :rows="6" placeholder="请输入审批意见"></el-input>
              </el-form>
              <span slot="footer" class="dialog-footer">
                <el-button @click="auditClose()">取 消</el-button>
                <el-button type="primary" @click="auditsure()">确 定</el-button>
              </span>
            </el-dialog>
          </el-row>
        </el-form>
      </el-col>
      <el-col :span="9" style="margin-left:20px">
        <div class="divRecom">
          <h4 class="recommend">当前推荐关系</h4>
          <div v-for="(i, index) in list.userList" :key="index" class="divFor">
            <div class="divBox">{{ i }}</div>
            <div v-if="index + 1 != list.userList.length" class="arrow">↓</div>
          </div>
        </div>
        <div class="divRecom">
          <h4 class="recommend">流水单推荐关系</h4>
          <div v-for="(i, index) in list.orderUserList" :key="index" class="divFor">
            <div class="divBox">{{ i.str }}</div>
            <div v-if="index + 1 != list.orderUserList.length" class="arrow">↓</div>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import {
  twoAudit,
  doTwoAudit,
  flashAudit,
  getReject
} from "@/api/subsidyManage";
export default {
  name: "SubsidyManageRecheck",
  filters: {
    filterNull(e) {
      if (!e) {
        return "暂无";
      } else {
        return e;
      }
    },
    cardNull(e) {
      return window.helper.cardType(e);
    },
    userFocus(e) {
      return window.helper.userFocus(e);
    }
  },
  data() {
    return {
      remark: "",
      radio: "1",
      number: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十"],
      val: "1",
      userId: "",
      list: {},
      dialogAudit: false,
      tableData: [
        {
          date: "2016-05-02",
          name: "王小虎"
        },
        {
          date: "2016-05-04",
          name: "王小虎"
        },
        {
          date: "2016-05-01",
          name: "王小虎"
        },
        {
          date: "2016-05-03",
          name: "王小虎"
        }
      ]
    };
  },
  mounted() {
    this.userId = String(this.$route.query.id);
    this.getList();
  },
  inject: ["reload"],
  methods: {
    refresh() {
      const datas = {
        id: this.userId
      };
      flashAudit(datas)
        .then(res => {
          if (!res.data.code) {
            this.$message.success("刷新成功");
            this.reload();
          } else {
            this.$message.error(res.data.msg);
          }
        })
        .catch(error => {
          this.$message.error(error);
        });
    },
    // 审批取消
    auditClose() {
      this.dialogAudit = false;
      // console.log("审核取消")
    },
    auditsure() {
      console.log(this.radio);
      if (this.radio == 1) {
        this.surefn();
      } else {
        const datas = {
          id: this.userId,
          applyStatus: this.radio,
          remark: this.remark
        };
         getReject(datas)
        .then(res => {
          console.log(res);
          if (!res.data.code) {
            this.$router.push("/subsidyManageIndex");
            this.reload();
          } else {
            this.$message.error(res.data.msg);
          }
        })
        .catch(error => {
          this.$message.error(error);
        });
      }
    },
    // 审批确定
    auditSubmit() {
      // console.log(this.list.formType)
      // if (this.list.formType) {
      //   if (this.list.formType.indexOf("传统") > -1) {
      //     this.dialogAudit = true;
      //     return false;
      //   }
      // }
      this.surefn();
    },
    surefn() {
      this.dialogAudit = false;
      const datas = {
        id: this.userId
      };

      doTwoAudit(datas)
        .then(res => {
          console.log(res);
          if (!res.data.code) {
            this.$router.push("/subsidyManageIndex");
            this.reload();
          } else {
            this.$message.error(res.data.msg);
          }
        })
        .catch(error => {
          this.$message.error(error);
        });
      console.log("审批确定");
    },
    getList() {
      const datas = { id: this.userId };
      twoAudit(datas)
        .then()
        .then(res => {
          console.log(res);
          console.log(res.data.data);
          if (!res.data.code) {
            this.list = res.data.data;
          } else {
            this.$message.error(res.data.msg);
          }
        })
        .catch(error => {
          this.$message.error(error);
        });

      // console.log(JSON.stringify(datas))
    }
  }
};
</script>

<style scoped>
.app-container {
  padding: 0px !important;
  background: transparent;
}
.spanToInput {
  width: 225px;
  /* overflow: hidden; */
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  border: 1px solid #ddd;
  text-align: left;
  padding: 0 12px;
}
.form {
  margin-left: 268px;
}
.divBox {
  min-width: 280px;
  color: #606266;
  text-align: center;
  border: 1px solid #e6e9f0;
  background: white;
  height: 30px;
  line-height: 30px;
}
.arrow {
  min-width: 280px;
  text-align: center;
  padding: 12px 0;
}
.recommend {
  min-width: 280px;
  color: #1d2023;
  font-size: 16px;
  text-align: center;
  font-weight: 500;
}
.divRecom {
  width: 48%;
  margin-left: 2%;
  float: left;
}
</style>
